<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        住院登记
    </title>
    <style>
        body{background-image: url("../images/djbjt.jpg")}
        .zhuyuan{
            /*border: 1px red solid;*/
            padding-left: 400px;
        }
        #topTitle{
            font-size: 20px;
            line-height: 50px;
            text-align: center;
        }
        label{line-height: 30px}
        button{
            width: 60px;
            display: inline-block;
            height: 38px;
            line-height: 38px;
            padding: 0 18px;
            background-color: #009688;
            color: #fff;
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            cursor: pointer;

        }
    </style>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../css/x-admin.css" media="all">
    <link rel="stylesheet" href="../css/pag.css" media="all">
    <%--<link type="text/css" rel="stylesheet" href="../js/jedate/test/jeDate-test.css">--%>
    <link type="text/css" rel="stylesheet" href="../js/jedate/skin/jedate.css">
    <script type="text/javascript" src="../js/jedate/src/jedate.js"></script>
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>住院管理</cite></a>
              <a><cite>住院登记</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="doRecord">
    <div id="topTitle" >
        <strong>住院病人登记</strong>
    </div>
    <div class="zhuyuan">
        <form id="zydjForm" name="zydjForm" method="post"
              action="${pageContext.request.contextPath }/djsave">
            <input type="hidden" name="method" value="add"/>
            <div>
                <label for="userId">住&nbsp;&nbsp;院&nbsp;&nbsp;号：</label>
                <input type="text" name="userId" id="userId" value="">
                <font color="red">*</font>
            </div>
            <div>
                <label for="userName">病人姓名：</label>
                <input type="text" name="userName" id="userName" value="">
                <font color="red"></font>
            </div>
            <div>
                <label >用户性别：</label>
                <select name="sex" id="sex">
                    <option value="1" selected="selected">男</option>
                    <option value="2">女</option>
                </select>
            </div>
            <div>
                <label for="age">年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄：</label>
                <input type="text" name="age" id="age" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="idCard">身份证号：</label>
                <input type="text" name="idCard" id="idCard" maxlength="18" value="">
                <font color="red"></font>
            </div>
            <div>
                <label >所属科室：</label>
                <select name="kId" id="kId" style="width: 90px;">
                    <option value="0" selected="selected">---请选择---</option>
                    <c:forEach var="keshi" items="${keshiList}">
                    <option value="${keshi.kid}">${keshi.kname}</option>
                    </c:forEach>
                </select>
                <font color="red"></font>
            </div>
            <div>
                <label for="docId">主治医师：</label>
                <select name="docId" id="docId" style="width: 90px;">
                    <option value="0" selected="selected">---请选择---</option>
                </select>
            </div>
            <div>
                <label >床&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
                <select name="bNo" id="bNo">
                    <option value="0" selected="selected">---请选择---</option>
                </select>
                <font color="red"></font>
            </div>
            <div>
                <label for="contacts">联&nbsp;&nbsp;系&nbsp;&nbsp;人：</label>
                <input type="text" name="contacts" id="contacts" value="">
            </div>
            <div>
                <label for="iphone">联系电话：</label>
                <input type="text" name="iphone" id="iphone" maxlength ="11" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="address">家庭地址：</label>
                <textarea name="address" id="address"  value="" style="width:200px; height:50px"></textarea>
            </div>

            <div class="jeinpbox">
                <label class="jelabel" for="checkInTime" style="text-align: right">入院时间：</label>
                <input type="text" name="checkInTime" class="jeinput" id="checkInTime" placeholder="请选择入院时间" align="center">
            </div>

            <div>
                <label for="summary">病情概要：</label>
                <textarea type="" name="summary" id="summary"  value="病情描述" style="width:200px; height:100px" ></textarea>
            </div>
            <div class="providerAddBtn" style="margin-bottom:50px;margin-left: 120px">
                <button type="button" name="add" id="add" >保存</button>
                <button type="button" id="back" name="back" >返回</button>
            </div>
        </form>
    </div>
</div>

<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script src="../js/x-layui.js" charset="utf-8"></script>
<script src="../js/jquery2.js" charset="utf-8"></script>
<script src="../js/js.js" charset="utf-8"></script>
<script src="../js/calendar/WdatePicker.js"></script>
<script src="../js/zygl/zydj.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
    });


    var enLang = {
        name: "en",
        month: ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
        weeks: ["SUN", "MON", "TUR", "WED", "THU", "FRI", "SAT"],
        times: ["Hour", "Minute", "Second"],
        timetxt: ["Time", "Start Time", "End Time"],
        backtxt: "Back",
        clear: "Clear",
        today: "Now",
        yes: "Confirm",
        close: "Close"
    }
    jeDate("#checkInTime", {
        festival: true,
        minDate: "1900-01-01",              //最小日期
        maxDate: "2099-12-31",              //最大日期
        method: {
            choose: function (params) {

            }
        },
        format: "YYYY-MM-DD hh:mm:ss"
    });

    //由科室选择框获取动态获取医生id
    $("#kId").change(function(){
        var skId = $("#kId").val();
        if(skId != '' && skId != null){
            $.ajax({
                type:"GET",//请求类型
                url:"/doctor",//请求的url
                data:{skId:skId},//请求参数
                dataType:"json",//ajax接口（请求url）返回的数据类型
                success:function(data){//data：返回数据（json对象）
                    $("#docId").html("");
                    var options = "<option value=\"0\" selected>---请选择---</option>";
                    for(var i = 0; i < data.length; i++){
                        options += "<option value=\""+data[i].docid+"\">"+data[i].docname+"</option>";
                    }
                    $("#docId").html(options);
                    var opt = "<option value=\"0\" selected>---请选择---</option>";
                    $("#bNo").html(opt);
                },
                error:function(data){//当访问时候，404，500 等非200的错误状态码
                    layer.msg("加载床位信息失败！");
                }
            });
        }else{
            $("#docId").html("");
            var options = "<option value=\"0\" selected>---请选择---</option>";
            $("#docId").html(options);
        }
    });

    //动态获取床位
    $("#docId").change(function() {
        var skId = $("#kId").val();
        if (skId != '' && skId != null) {
            $.ajax({
                type: "GET",//请求类型
                url: "/bedList",//请求的url
                data: {kId: skId},//请求参数
                dataType: "json",//ajax接口（请求url）返回的数据类型
                success: function (data) {//data：返回数据（json对象）
                    $("#bNo").html("");
                    var options = "<option value=\"0\" selected>---请选择---</option>";
                    for (var i = 0; i < data.length; i++) {
                        options += "<option value=\"" + data[i].bNo + "\">" + data[i].bNo + "</option>";
                    }
                    $("#bNo").html(options);
                },
                error: function (data) {//当访问时候，404，500 等非200的错误状态码
                    layer.msg("加载床位信息失败！");
                }
            });
        } else {
            $("#bNo").html("");
            var options = "<option value=\"0\" selected>---请选择---</option>";
            $("#bNo").html(options);
        }
    });
//    年龄格式验证
    $("#age").blur(function () {
        var age = $("#age").val();
        var regex = /^[0-9]{1,3}$/;
        if (regex.test(age)){
            $("#age").next().css({"color":"green"}).html("✔");
        }else {
            $("#age").next().css({"color":"red"}).html("请输入1-3位数字");
        }
    });

//    电话号码格式验证
    $("#iphone").blur(function () {
        var age = $("#iphone").val();
        var regex = /^[0-9]{1,11}$/;
        if (regex.test(age)){
            $(this).next().css({"color":"green"}).html("✔");
        }else {
            $(this).next().css({"color":"red"}).html("请输入不多于11位数字");
        }
    });

//    18位身份证验证
    $("#idCard").blur(function () {
        var idCard = $("#idCard").val();
        var regex = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
        if (regex.test(idCard)){
            $(this).next().css({"color":"green"}).html("✔");
        }else {
            $(this).next().css({"color":"red"}).html("身份证号格式不匹配");
        }
    });

//  住院号ajax验证
    $("#userId").blur(function () {
        var userId = $("#userId").val();
        $.ajax({
            type:"get",
            url:"/idConfirm/"+userId,
            // date:{userId:userId},
            dateType:"json",
            success:function(data){
                var flag = data.retMsg;
                if (flag){
                $("#userId").next().css({"color":"green"}).html("✔");
                }else {
                $("#userId").next().css({"color":"red"}).html("该病人已住院，无需登记");
                }
            },
            error:function () {
                $("#userId").next().css({"color":"red"}).html("请输入住院号");
            }
        });
    })
</script>
</body>
</html>